﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Openfree.Framework.DataAccess;
using System.Text;

public partial class PMSWeb_DesktopStock : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string cmdText = string.Format("SELECT top 7 T.*,A.CodeName AS RequisitionTypeName,TU.UserName as UserName,ORG.Subject as OrgName FROM {0} T LEFT JOIN T_User TU on TU.UserId=T.loginName LEFT JOIN T_OrgPool ORG on ORG.OrgId=T.Department LEFT JOIN " + SqlCodeConfig.TableName + " A ON A.CodeValue=T.RequisitionType AND A.Category='" + PMSCodeCategory.PMS_CKLX + "' where 1=1 ORDER BY CREATETIME DESC", "IC_Requisition");
            DataSet ds = PMSAccess.GetDataSet(this.Connection, cmdText);
            StringBuilder sbTemp = new StringBuilder();
            int index = 1;
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                sbTemp.AppendLine("<tr>");
                sbTemp.AppendLine("<td><img src=\"../App_Themes/DefaultSkin/Image/da" + index.ToString() + ".jpg\" alt=\"" + index.ToString() + "\" ></td>");
                sbTemp.AppendLine("<td>" + row["RequisitionUser"].ToString() + "</td>");
                sbTemp.AppendLine("<td><a target='_parent' href='../PMSWeb/ReqOutManager.aspx?RequisitionId=" + row["RequisitionId"].ToString() + "''>" + row["RequisitionTypeName"].ToString() + "</a></td>");
                sbTemp.AppendLine("<td>" + row["UserName"].ToString() + "</td>");
                sbTemp.AppendLine("<td>" + (row["RequisitionDate"] == DBNull.Value ? "" : Convert.ToDateTime(row["RequisitionDate"].ToString()).ToString("MM-dd HH:ss")) + "</td>");
                sbTemp.AppendLine("<tr>");
                index++;
            }
            for (int i = index; i < 8; i++)
            {
                sbTemp.AppendLine("<tr>");
                sbTemp.AppendLine("<td>&nbsp;</td>");
                sbTemp.AppendLine("<td>&nbsp;</td>");
                sbTemp.AppendLine("<td>&nbsp;</td>");
                sbTemp.AppendLine("<td>&nbsp;</td>");
                sbTemp.AppendLine("<td>&nbsp;</td>");
                sbTemp.AppendLine("<tr>");
            }

            literal.Text = sbTemp.ToString();
        }
    }
}